import 'package:flutter/material.dart';

class Exam_4 extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: AppBar(
        title: Text("文本及样式"),
      ),
      body: Content(),
    );
  }


}

class Content  extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return ListView(
      children: <Widget>[
        Text(
          "Hello world",
          textAlign: TextAlign.left,
        ),

        Text(
          "Hello world" * 40,
          maxLines: 1,
          overflow: TextOverflow.ellipsis,
        ),

        Text(
          "Hello world",
          textScaleFactor: 5.0, //缩放因子
        ),

        Text(
          "Hello world",
          style: TextStyle(
            color: Colors.blue,
            fontSize: 18.0,//精确指定字体大小，textScaleFactor只能通过缩放比例来控制大小
            height: 1.2,//行高因子，行高=fontsize * height
            fontFamily: "Courier",//设置字体集
            background: new Paint()..color = Colors.yellow,
            decoration: TextDecoration.underline,
            decorationStyle: TextDecorationStyle.dashed
          ),
        ),

        /**富文本*/
        Text.rich(TextSpan(
          children: [
            TextSpan(
              text: "Home:"
            ),
            TextSpan(
              text: "https://www.baidu.com",
              style: TextStyle(
                color: Colors.blue
              ),
            )
          ]
        )),

        DefaultTextStyle(
          //1.设置文本默认样式
          style: TextStyle(
            color: Colors.red,
            fontSize: 20.0,
          ),
          textAlign: TextAlign.start,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Text("I am jack"),
              Text("I am jreey"),
              Text("I am jack",
               style: TextStyle(
                 inherit: false,//不继承默认样式
                 color: Colors.grey
               ),),
            ],
          ),
        ),
      ],
    );
  }
}